#define _CRT_SECURE_NO_WARNINGS


#include		<stdio.h>
#include		<stdlib.h>
#include		<time.h>
#include		<math.h>
#include		<string.h>
#include		<ctype.h>
#include        <assert.h>
#include		<windows.h>
#include		<errno.h>

int is_left_move(const char* mother, const char* son);
int is_left_move2(const char* mother, const char* son);

int main()
{
	char str1[50] = "abcdefg";
	char str2[] = "abcdefg";

	int output = 0;
	while (1)
	{
		scanf("%s", &str2);
		//output = is_left_move(str1, str2);
		output = is_left_move2(str1, str2);
		printf("%d\n", output);
	}
	return 0;
}




int is_left_move(const char* mother, const char* son)
{
	int len1 = strlen(mother);
	int len2 = strlen(son);
	if (len1 == len2)
	{
		char son1[50] = " ";
		strcpy(son1, mother);
		int count = 0;
		int cycle = len1;
		while (cycle--)
		{
			count = strcmp(son1, son);
			if (count == 0)
			{
				return 1;
			}
			char tmp = *son1;
			memmove(son1, son1 + 1, len1 - 1);
			*(son1 + len1 - 1) = tmp;

		}
		return 0;
	}
	else
		return 0;
}


int is_left_move2(const char* mother, const char* son)
{
	int len1 = strlen(mother);
	int len2 = strlen(son);
	if (len1 == len2)
	{
		char son1[100] = " ";
		strcpy(son1, mother);
		strcat(son1, mother);
		char* str = strstr(son1, son);
		if (str == NULL)
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
	else
		return 0;
}
